﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Jayden.Dll.ECMAScript
{
	public class IfOperator : Operator
	{
		private Expression m_LogicalExpression;
		private Expression m_TrueExpression;
		private Expression m_FalseExpression;

		public IfOperator(Expression logicalExpr, Expression trueExpr, Expression falseExpr)
		{
			m_LogicalExpression = logicalExpr;
			m_TrueExpression = trueExpr;
			m_FalseExpression = falseExpr;
		}

		public void RenderExpression(StringBuilder builder)
		{
			ExpressionList.RenderOperatorExpression(this, m_LogicalExpression, builder);
			builder.Append(" ? ");
			ExpressionList.RenderOperatorExpression(this, m_TrueExpression, builder);
			builder.Append(" : ");
			ExpressionList.RenderOperatorExpression(this, m_FalseExpression, builder);
		}

		public int Precedence { get { return 15; } }
	}
}
